package online.hxstart.code.concurrent.chapter01;

/**
 * @author huxing
 * @date 19-4-22 星期一 下午2:16
 * @describe
 */
public class TryConcurrency {

  public static void main(String[] args) {
    //
    Thread thread = new Thread(TryConcurrency::enjoyMusic);
    thread.setDaemon(true);
    thread.start();
    // thread.start();
    // thread.start();
    //    browseNews();
  }

  private static void browseNews() {
    while (true) {
      System.out.println("news");
      sleep(1);
    }
  }

  private static void enjoyMusic() {
    while (true) {
      System.out.println("music");
      sleep(1);
    }
  }

  private static void sleep(int i) {
    try {
      Thread.sleep(i * 1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
// 生命周期 new 新建 创建一个对象
// runnanle 就绪状态，可执行状态
// running 执行状态 执行逻辑代码--（runnable）
//    ---terminated 终止状态
//    ---blocked 阻塞状态
